import { App } from 'vue';
import {
	createRouter,
	createWebHashHistory,
	createWebHistory,
	RouteRecordRaw,
} from 'vue-router';
import { basicRoutes } from './routes';
import { ProjectSetting } from '../setting';
import { qiankunWindow } from 'vite-plugin-qiankun/dist/helper'
export const router = createRouter({
	history:
		ProjectSetting.routeMode === 'HASH'
			? createWebHashHistory()
			: createWebHistory(qiankunWindow.__POWERED_BY_QIANKUN__ ? ProjectSetting.microSetting.baseUrl : ProjectSetting.resourceBaseUrl),
	routes: basicRoutes as RouteRecordRaw[],
});

export function setupRouter(app: App<Element>) {
	app.use(router);
}
